const express = require("express")
const router = express.Router()
const vistorDB = require("../db/vistor")

// 留言
router.use("/",require("./message/message"))

// 后台系统
router.use("/admin",require("./admin/index"))

// 访客来访
router.get("/vistor",async(req,res)=>{
  try {
    // await vistorDB.create({vistor:210})
    let doc = await vistorDB.findByIdAndUpdate("6141f2c586c55297f60e79e5",{
      $inc:{
        vistor:1
      }
    })
    res.send({
      code:0,
      mes:"访客列表",
      data:doc
    })
  } catch (error) {
    res.send({
      code:5,
      mes:"服务器异常，请稍后再试"
    })
  }
})

// 客户端
router.use("/client",require("./client/index"))

module.exports = router